package com.moguhoutai.biz;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.moguhoutai.dao.AdminMapper;
import com.moguhoutai.model.Admin;
import com.moguhoutai.util.BusinessException;
import com.moguhoutai.util.Constants;
import com.moguhoutai.util.EncryptHelper;

@Service
public class AdminBiz {
	@Resource
	private AdminMapper admindao;

	public Admin login(Admin admin) throws BusinessException {
		String encryptedPwd = EncryptHelper.getMD5(admin.getPwd());
		try {
			return admindao.findBynameandPwd(admin.getUserName(), encryptedPwd);
		} catch (Exception e) {
			e.printStackTrace();
			throw new BusinessException(Constants.LOGIN_EXCEPTION_CODE);
		}
	}
}
